//package com.allwees.bs.module.pms.score;
//
//import static com.allwees.bs.module.pms.score.ProductScore.CRAWL_POS;
//import static com.allwees.bs.module.pms.score.ProductScore.PLATFORM_INTERVENE;
//import static com.allwees.bs.module.pms.score.ProductScore.PUBLISH_DATE;
//import static com.allwees.bs.module.pms.score.ProductScore.TOTAL_COLLECTIONS;
//import static com.allwees.bs.module.pms.score.ProductScore.TOTAL_GOOD_RATINGS;
//import static com.allwees.bs.module.pms.score.ProductScore.TOTAL_SALES;
//import static com.allwees.bs.module.pms.score.ProductScore.TOTAL_VIEWS;
//
//import java.util.Date;
//
//import com.allwees.bs.module.pms.entity.Product;
//import com.allwees.core.common.util.DateUtil;
//
///**
// * 商品Score计算器
// *
// * @author yangylsky
// * @since 2020-03-12
// *
// */
//public class ProductScoreCaculator {
//	public static Double caculateScore(Product product) {
//		Double posIdxScore = CRAWL_POS.caculateScore(fix2Double(product.getPosIdx()));
//		Double totalSalesScore = TOTAL_SALES.caculateScore(fix2Double(product.getTotalSales()));
//		Double totalCollectionsScore = TOTAL_COLLECTIONS.caculateScore(fix2Double(product.getTotalCollections()));
//		Double ratingScore = TOTAL_GOOD_RATINGS.caculateScore(fix2Double(product.getRating()));
//		Double totalViewsScore = TOTAL_VIEWS.caculateScore(fix2Double(product.getTotalViews()));
//		Double publishDateScore = PUBLISH_DATE.caculateScore(fixPublishDate(product.getPublishAt()));
//		Double platformInterveneScore = PLATFORM_INTERVENE.caculateScore(fix2Double(product.getPlatformIntervene()));
//
//		return posIdxScore + totalSalesScore + totalCollectionsScore + ratingScore + totalViewsScore + publishDateScore + platformInterveneScore;
//	}
//
//	private static Double fix2Double(Number x) {
//		return x == null ? null : x.doubleValue();
//	}
//
//	/**
//	 * publishDate当前秒数 - 当前日期下一天00:00秒数
//	 *
//	 * @param publishDate
//	 * @return
//	 */
//	private static Double fixPublishDate(Date publishDate) {
//		return publishDate == null ? null : (publishDate.getTime() / 1000.0) - (DateUtil.truncateToDay(1).getTime() / 1000.0);
//	}
//}
